<?
 

function TPfromFile($filename) {
	$lines=file($filename);
	$i=0;
	foreach ($lines as $line ){
		if ($line[0]!='W') continue;
		// W  T02053 A 41.1693666667?N 24.1735166667?E 27-MAR-62 00:00:00 528.799988 START KORYL_EAST
		$parts=split(" ",$line,10);

		$latTmp=$parts[4];
		$lonTmp=$parts[5];

		$lat=substr($latTmp,0,-2);
		$lon=substr($lonTmp,0,-2);
		if (substr($latTmp,-1) =='S' ) $lat=-$lat;
		if (substr($latTmp,-1) =='W' ) $lon=-$lon;

		$tp[$i]['name']=trim($parts[2]);
		$tp[$i]['desc']=trim($parts[9]);
		if ( !$tp[$i]['desc'] ) $tp[$i]['desc']=$tp[$i]['name'];

		$tp[$i]['lat']=$lat;
		$tp[$i]['lon']=$lon;
		$tp[$i]['alt']=floor(trim($parts[8])+0);

		$i++;

	}
	usort($tp, "cmpTp");
	return $tp;
}

		// sort pilots with last name , fist name
		function cmpTp ($a1, $b1) { 
			$a=$a1["name"];
			$b=$b1["name"]; 
			if ($a == $b) return 0; 
			return ($a > $b) ? 1 : -1; 
		} 
		

?>